package com.lly.bigdata.bgayx.controller;/**
 * Created by Administrator on 2019/7/9 0009.
 */

import com.lly.bigdata.bgayx.common.utils.SecurityUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.Set;

/**
 * @author Administrator
 * @description
 * @date 2019/7/9 0009
 */
@Controller
public class GoToController {

    @GetMapping("/login")
    public String login() {
        return "login";
    }

    @RequestMapping("/mge/adx/{v}/{d}")
    public String go1(HttpServletRequest request, @PathVariable String v, @PathVariable String d, Model model) {
        Map<String, String[]> pars = request.getParameterMap();
        if (pars != null && pars.size() > 0) {
            Set<Map.Entry<String, String[]>> ens = pars.entrySet();
            for (Map.Entry<String, String[]> vals : ens) {
                model.addAttribute(vals.getKey(), StringUtils.join(vals.getValue(), ","));
            }
        }
        return "/mge/adx/" + v + "/" + d;
    }

    @RequestMapping("/mge/adx/{v}")
    public String go1(HttpServletRequest request, @PathVariable String v, Model model) {
        Map<String, String[]> pars = request.getParameterMap();
        if (pars != null && pars.size() > 0) {
            Set<Map.Entry<String, String[]>> ens = pars.entrySet();
            for (Map.Entry<String, String[]> vals : ens) {
                model.addAttribute(vals.getKey(), StringUtils.join(vals.getValue(), ","));
            }
        }
        model.addAttribute("username", SecurityUtils.getLoginUser().getUsername());
        return "/mge/adx/" + v;
    }

}
